package org.cfg;

import com.sojoys.artifact.build.data.base.BaseCfg;
import java.util.List;
import com.sojoys.artifact.tools.ToolMap;
import com.sojoys.artifact.tools.ToolCopy;
import com.sojoys.artifact.factory.bytebuff.IByteBuff;
import java.util.Map;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.ArrayUtils;
import com.sojoys.artifact.tools.SK_String;
import com.xiaoleilu.hutool.util.StrUtil;
import com.sojoys.artifact.constant.DataModelKeyEnum;
/**
 * 灵装经验
 */
public class EquipmentGrowthCfg extends BaseCfg<EquipmentGrowthCfg> {

	/**
	 * 数据库表名称
	 */
	public static final String TABLE_NAME = "equipment_growth";
	/**
	 * 完整类名称
	 */
	public static final String CLASS_NAME = "org.cfg.EquipmentGrowthCfg"; 
	/**
	 * 字段个数
	 */
	public static final int COLUMN_COUNT= 3;
	/**
	 * 数据库源字段注释
	 */
	public static final String[] SOURCE_COLUMN_REMARKS = new String[]{"","星级","所需经验（非累计）",};
	/**
	 * 数据库源字段名字
	 */
	public static final String[] SOURCE_COLUMN_NAMES = new String[]{"id","star","needExp",};
	/**
	 * 拼音字段名字
	 */
	public static final String[] PINGYING_COLUMN_NAMES = new String[]{"id","star","needExp",};
	/**
	 * HashCode字段名字
	 */
	public static final Integer[] HASHCODE_COLUMN_NAMES = new Integer[]{3355,3540562,1829026215,};
	/**
	 * 字段基本类型
	 */
	public static final String[] COLUMN_BASICTYPES = new String[]{"int","int","int[]",};
	/**
	 * 字段引用类型
	 */
	public static final Class[] COLUMN_CLASSTYPES = new Class[]{Integer.class,Integer.class,int[].class,};
	
	/**
	 * id
	 */
	private int id;
	
	/**
	 * 星级
	 */
	private int star;
	
	/**
	 * 所需经验（非累计）
	 */
	private int[] needExp;
	
	
	
	public static EquipmentGrowthCfg builder() {
		EquipmentGrowthCfg equipmentGrowthCfg = new EquipmentGrowthCfg();
		return equipmentGrowthCfg;
	}
	
	/**
	 * id
	 */
	public int getId() {
		return id;
	}
	
	/**
	 * 星级
	 */
	public int getStar() {
		return star;
	}
	
	/**
	 * 所需经验（非累计）
	 */
	public int[] getNeedExp() {
		return needExp;
	}
	
	
	protected Object[] getColumnNames(DataModelKeyEnum e){
		switch (e) {
		case SOURCE:
			return SOURCE_COLUMN_NAMES;
		case PINGYING:
			return PINGYING_COLUMN_NAMES;
		case HASHCODE:
			return HASHCODE_COLUMN_NAMES;
		case REMARKS:
			return SOURCE_COLUMN_REMARKS;
		default:
			return PINGYING_COLUMN_NAMES;
		}
	}
	
	protected String[] getBasicTypes(){
		return COLUMN_BASICTYPES;
	}
	
	protected Class[] getClassTypes(){
		return COLUMN_CLASSTYPES;
	}
	
	protected Object[] getColumeValues(){
		Object[] values = new Object[COLUMN_COUNT];
        values[0] = this.id;
        values[1] = this.star;
        values[2] = this.needExp;
        return values;
	}
	
	protected EquipmentGrowthCfg createColumeValues(Object[] vals) {
		this.id = (int)vals[0];
		this.star = (int)vals[1];
		this.needExp = (int[])vals[2];
		return this;
	}
	
	protected Map<Object, Object> toMap(Object[] keys,Map<Object, Object> map){
        map.put(keys[0], this.id);
        map.put(keys[1], this.star);
        map.put(keys[2], this.needExp);
        return map;
    }
    
    protected EquipmentGrowthCfg createForMap(Object[] keys,Map map){
   		this.id = (int)map.get(keys[0]);
   		this.star = (int)map.get(keys[1]);
   		this.needExp = (int[])map.get(keys[2]);
        return this;
    }
	
	
	protected JSONObject toJSONObject(Object[] keys,JSONObject obj){
        obj.put(keys[0], this.id);
        obj.put(keys[1], this.star);
        obj.put(keys[2], this.needExp);
        return obj;
    }
    
    protected EquipmentGrowthCfg createForJSONObject(Object[] keys,JSONObject obj){
	    this.id = obj.getIntValue(keys[0]);
	    this.star = obj.getIntValue(keys[1]);
		this.needExp = obj.getObject(keys[2],int[].class);
        return this;
    }
    
    protected void writeBytes(IByteBuff byteBuf){
	    byteBuf.writeInt(this.id);
	    byteBuf.writeInt(this.star);
	    byteBuf.writeObject(this.needExp);
    }
	
	protected EquipmentGrowthCfg readBytes(IByteBuff byteBuf){
	    this.id = byteBuf.readInt(null);
	    this.star = byteBuf.readInt(null);
	    this.needExp = byteBuf.readIntArray(null);
	    return this;
	}
	
	public EquipmentGrowthCfg deepCopy(){
		EquipmentGrowthCfg equipmentGrowthCfg = null;
		try {
			equipmentGrowthCfg = (EquipmentGrowthCfg) super.clone();
		    equipmentGrowthCfg.needExp = ToolCopy.copyObject(this.needExp);
			return equipmentGrowthCfg;
		} catch (CloneNotSupportedException e) {
			e.printStackTrace();
		}
		return equipmentGrowthCfg;
	}
//自定义内容起始位置
//自定义内容结束位置
}
